package com.stream;

/**
 * @author weijingchen
 * @DateTime 2025-06-16
 */
public class User {
    private String name;
    private Integer age;

    public User() {
    }

    public User(String name, Integer age) {
        if (name.length() < 3 | name.length() > 12) {
            throw new IllegalArgumentException();
        }
        if (age<18 | age>40){
            throw new IllegalArgumentException();
        }
        this.name = name;
        this.age = age;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        if (name.length() < 3 | name.length() > 12) {
            throw new IllegalArgumentException();
        }
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public Integer getAge() {

        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(Integer age) {
        if (age<18 | age>40){
            throw new IllegalArgumentException();
        }
        this.age = age;
    }

    public String toString() {
        return "User{name = " + name + ", age = " + age + "}";
    }
}
